package br.com.beethoven.model.service;

import java.util.ArrayList;
import java.util.List;

import br.com.beethoven.data.interfaces.ICdDAO;
import br.com.beethoven.data.interfaces.impl.CdHibernateDAO;
import br.com.beethoven.exception.BDException;
import br.com.beethoven.model.entidade.CD;
import br.com.beethoven.model.entidade.vo.CD_VO;

public class ServiceGerenciarCD {
	
	private ICdDAO iCdDAO;
	
	public ServiceGerenciarCD(){
		this.iCdDAO = new CdHibernateDAO();
	}
	
	public void cadastrar(CD_VO cd_VO) throws BDException {
		CD cd = new CD();
		cd.VO2entity(cd_VO);
		this.iCdDAO.addEntity(cd);
	}
	
	public void editar(CD_VO cd_VO) throws BDException{
		CD cd = new CD();
		cd.VO2entity(cd_VO);
		this.iCdDAO.updateEntiy(cd);
	}
	
	public void remover(CD_VO cd_VO) throws BDException{
		CD cd = new CD();
		cd.VO2entity(cd_VO);
		this.iCdDAO.removeEntity(cd);
	}
	
	public List<CD_VO> listar() throws BDException{
		List<CD_VO> lista = new ArrayList<CD_VO>();
		List<CD> listaAux = new ArrayList<CD>();
		listaAux = this.iCdDAO.listAll();
		for(CD cd : listaAux){
			lista.add(cd.entity2VO());
		}
		return lista;
	}

	public boolean validar(CD_VO cd_VO){
		return true;
	}

}
